home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tex / inputs / cite.sty < prev    next >
Encoding:
Text File  |  1991-05-21  |  3.8 KB  |  96 lines

  1. %     CITE.STY -- compress numerical citations.
  2. %     See also OVERCITE.STY.
  3. %
  4. %     Copyright (C) 1989,1990 by Donald Arseneau
  5. %     These macros may be freely transmitted, reproduced, or modified for
  6. %     non-commercial purposes provided that this notice is left intact.
  7. %     
  8. %     Instructions follow \endinput.
  9. %  ------------------------------------
  10. %
  11. %  Pull out the code that writes the aux file citation and formats 
  12. %  the number.  \citen can be used by itself to give citation numbers 
  13. %  without the other formatting; e.g., "See also ref.~\citen{junk}."
  14. %
  15. \def\citen#1{%
  16. \if@filesw \immediate \write \@auxout {\string \citation {#1}}\fi 
  17. \@tempcntb\m@ne \let\@h@ld\relax \def\@citea{}%
  18. \@for \@citeb:=#1\do {%
  19.   \@ifundefined {b@\@citeb}%
  20.     {\@h@ld\@citea\@tempcntb\m@ne{\bf ?}%
  21.     \@warning {Citation `\@citeb ' on page \thepage \space undefined}}%
  22. % else, defined
  23.     {\@tempcnta\@tempcntb \advance\@tempcnta\@ne
  24.     \setbox\z@\hbox\bgroup % check if citation is a number:
  25.     \ifnum0<0\csname b@\@citeb \endcsname \relax
  26.        \egroup \@tempcntb\number\csname b@\@citeb \endcsname \relax
  27.        \else \egroup \@tempcntb\m@ne \fi
  28.     \ifnum\@tempcnta=\@tempcntb % Number follows previous--hold on to it
  29.        \ifx\@h@ld\relax % first pair of successives
  30.           \edef \@h@ld{\@citea\csname b@\@citeb\endcsname}% 
  31.        \else % compressible list of successives
  32. %         % use \hbox to avoid easy \exhyphenpenalty breaks 
  33.           \edef\@h@ld{\hbox{--}\penalty\@highpenalty
  34.             \csname b@\@citeb\endcsname}%
  35.        \fi
  36.     \else   %  non-successor--dump what's held and do this one
  37.        \@h@ld\@citea\csname b@\@citeb \endcsname 
  38.        \let\@h@ld\relax
  39.     \fi}%
  40. %%    To put space after the comma, use:
  41.  \def\@citea{,\penalty\@highpenalty\hskip.13em plus.1em minus.1em}%
  42. %%    For no space after comma, use:
  43. %% \def\@citea{,\penalty\@highpenalty}% 
  44. %%
  45. }\@h@ld}
  46. %     Replacement for \@citex:
  47. \def\@citex[#1]#2{\@cite{\citen{#2}}{#1}}%
  48. %
  49. %  Replacement for \@cite 
  50. %
  51. \def\@cite#1#2{\leavevmode\unskip
  52.   \ifnum\lastpenalty=\z@\penalty\@highpenalty\fi% highpenalty before
  53.   \ [{\multiply\@highpenalty 3 #1%             % triple-highpenalties within
  54.       \if@tempswa,\penalty\@highpenalty\ #2\fi % and before note.
  55.     }]\spacefactor\@m}
  56. %
  57. \endinput
  58. %
  59. %     
  60. %                          CITE.STY
  61. %
  62. %     Modify LaTeX's normal citation mechanism to:
  63. %
  64. %     o Allow, but strongly discourage, line breaks within a series of
  65. %       citations.  Each number is separated by a comma and a small space.
  66. %       A break at the beginning of an optional note is discouraged also.
  67. %
  68. %     o Compress lists of three or more consecutive numbers to one number 
  69. %       range which can be split, with difficulty, after the dash.  No sorting
  70. %       to optimize compression is done.  All numbers should be greater than
  71. %       zero. E.g., if you used to get [5,6,7,9,8,Einstein,6], then this style 
  72. %       will give you [5--7,9,8,Einstein,6]. 
  73. %
  74. %     o Always puts an interword space before the citation and allow a 
  75. %       highpenalty break there (unless you specifically forbid it with ~).
  76. %       E.g.,   Something really stupid \cite{Larry,Curly,Moe}.
  77. %                                      ^-- This space doesn't matter.
  78. %
  79. %     To get just the numbers (and write to the aux file) without the
  80. %     extra formatting, use \citen just like \cite.
  81. %
  82. %     Linebreaks are allowed with triple-highpenalties after dashes
  83. %     and commas; these may have to be taken if TeX sees no other 
  84. %     viable breakpoints.  If you think citations are being split 
  85. %     unnecessarily, try using \sloppy or a sloppypar environment.
  86. %
  87. %     FRAGILE!
  88. %
  89. % Send problem reports to asnd@triumfcl.bitnet or Arseneau@mtsg.ubc.ca
  90. %
  91. % test integrity:
  92. % brackets: round, square, curly, angle:   () [] {} <>
  93. % backslash, slash, vertical, hat, tilde:   \ / | ^ ~
  94.